package cc;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

import org.apache.commons.codec.binary.Hex;

import com.alibaba.fastjson.JSON;
import com.bootdo.common.utils.HttpUtil;
import com.bootdo.common.utils.StrUtil;
import com.bootdo.system.config.KswApi;

public class KswCc {
	//41673
	public static void main(String[] args) {
			String key="62195e1ab9c6287c5b66fff4951bce85";
			TreeMap<String, String> treeMap = new TreeMap<String, String>();
		    treeMap.put("key" , key);
		    treeMap.put("oid" , "19054221312192526");
		    treeMap.put("full" , "1");
		    treeMap.put("type" , "4");
		    treeMap.put("sign" , genSign(treeMap));
		    String s = HttpUtil.doGet(KswApi.MTLM_ORDER,treeMap);
		    System.out.println(s);
		    HashMap<String,Map<String,Object>> hashMap = JSON.parseObject(s, HashMap.class);
		    Map<String, Object> map = hashMap.get("order");
		    Integer object2 = (Integer) map.get("status");
		    System.out.println(object2);
	}
	
	//java 
	public static String genSign(TreeMap<String, String> params) {
		if (params.containsKey("sign")) {
		    params.remove("sign");
		}
		String str = "";
		str += "87d6e369dcb70538f422f703b5293552";
		for (String key : params.keySet()) {
		    str += key + params.get(key);
		}
		str += "87d6e369dcb70538f422f703b5293552";
		String sign = md5(str);
		return sign;
	}
	public static String md5(String source) {
		String md5Result = null;
		try {
		        byte[] hash = org.apache.commons.codec.binary.StringUtils.getBytesUtf8(source);
		        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
		        messageDigest.update(hash);
		        hash = messageDigest.digest();
		        md5Result = Hex.encodeHexString(hash);
		} catch (NoSuchAlgorithmException e) {
		        e.printStackTrace();
		}
		return md5Result;
	}

}
